package cn.tsmchina.one.dao.config;

import org.springframework.stereotype.Repository;

import cn.tsmchina.one.dao.BaseDaoSupport;
import cn.tsmchina.one.domain.config.Config;

/** 
 * 
 * @author locoroco.rao
 * @date   2013-10-29
 * Copyright: Copyright (c) 2013 TSM,Inc
 */

@Repository
public class ConfigDaoImpl extends BaseDaoSupport<Config> implements ConfigDao {

	@Override
	public Config getConfig(long customerId, String configKey) {
		String hql = "from Config c where c.customerId = ? and c.configKey = ?";
		return (Config) find(hql, customerId, configKey);
	}

	@Override
	public int updateIndexImage(int configId, String imagePath) {
		String hql = "update Config c set c.configValue=? where c.id=?";
		return super.executeUpdate(hql, imagePath, configId);
	}

	@Override
	public int addIndexImage(long customerId, String imagePath, String configKey) {
		Config config = new Config();
		config.setConfigKey(configKey);
		config.setCustomerId(customerId);
		config.setConfigValue(imagePath);
		return (Integer)super.add(config);
	}

}
